wx.cloud.init()
const db = wx.cloud.database()
Page({
  data: {
    orderState: ["待确认", "已确认", "已完成"],
    orderDesc: ["订单已提交，请进行现场确认", "确认已经完成，请飞手进行喷洒", "订单已完成"],
    flag: 0,
    orderDetails: [],
  },
  onLoad: function (e) {
    db.collection('Order').where({
      _id: e._id
    }).get({
      success: res => {
        this.setData({
          orderDetails: res.data,
          flag: res.data[0].orderState,
          b_id: res.data[0]._id
        })
      }
    })
    console.log(this.data.orderDetails)
  },
  //取消订单
  buttonOnClick_delOrderfunction(e) {
    // console.log(this.data.b_id)
    db.collection('Order').doc(this.data.b_id).remove({
      success: res => {
        wx.navigateBack({
          delta: 1
        })
        wx.showToast({
          title: '您已取消订单',
        })
      },
      fail: console.error
    })
  },

  //修改订单
  modifyOrder: function (e) {
    console.log(this.data.b_id)
    wx.redirectTo({
      url: '../../order/modifyOrder/modifyOrder?_id=' + this.data.b_id
    })
  },

})